package bishi;

import java.util.Scanner;

/**
 * @Author liuhaoqi
 * @Date 2020/9/13 16:16
 * @Version 1.0
 */
public class CCF20200902 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int t = scanner.nextInt();
        int x1 = scanner.nextInt();
        int y1 = scanner.nextInt();
        int x2 = scanner.nextInt();
        int y2 = scanner.nextInt();
        int num1 = 0;
        int num2 = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int[][] arr = new int[t][2];
            for (int j = 0; j < t; j++) {
                arr[j][0] = scanner.nextInt();
                arr[j][1] = scanner.nextInt();
            }
            int flag = 0;
            int isflunum = 0;
            for (int j = 0; j < t; j++) {
                if (arr[j][0] >= x1 && arr[j][0] <= x2 && arr[j][1] >= y1 && arr[j][1] <= y2) {
                    isflunum++;
                    if (isflunum >= max) {
                        max = isflunum;
                    }
                    flag++;
                } else {
                    isflunum = 0;
                }
            }
            if (flag > 0) {
                num1++;
            }
            if (max >= k) {
                num2++;
            }
            max = 0;
        }
        System.out.println(num1);
        System.out.println(num2);
    }
}
